package main

import (
	"fmt"
	"os"
	"syscall"
)

func main() {
	var stat syscall.Statfs_t

	wd, _ := os.Getwd()

	syscall.Statfs(wd, &stat)

	// Available blocks * size per block = available space in bytes
	fmt.Println(stat.Bavail * uint64(stat.Bsize))
}

// 目录或者文件是否存在
func existed(path string) (bool, error) {
	_, err := os.Stat(path)
	if err != nil && !os.IsNotExist(err) {
		fmt.Println(err.Error())
		return false, err
	}

	if os.IsNotExist(err) {
		return false, nil
	}

	return true, nil

}

func createDir(dir string) error {
	return os.MkdirAll(dir, 0777)
}
